package com.lzy.cloud.permission.service.impl;

import com.lzy.cloud.permission.dtos.RoleResourcePermissionDto;
import com.lzy.cloud.permission.entity.RoleResourcePermissionKey;
import com.lzy.cloud.permission.mapper.RoleResourcePermissionMapperExt;
import com.lzy.cloud.permission.service.RoleResourcePermissionService;
import com.lzy.framework.core.utils.DozerUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by WIN7 on 2018/5/17.
 */
@Service
public class RoleResourcePermissionServiceImpl implements RoleResourcePermissionService{

    @Autowired
    RoleResourcePermissionMapperExt roleResourcePermissionMapperExt;

    @Override
    public Boolean insert(RoleResourcePermissionDto roleResourcePermissionDto) {
        return roleResourcePermissionMapperExt.insertSelective(DozerUtils.map(roleResourcePermissionDto,RoleResourcePermissionKey.class))>0;
    }

    @Override
    public Boolean update(RoleResourcePermissionDto roleResourcePermissionDto) {
        return null;
    }

    @Override
    public Boolean delete(RoleResourcePermissionDto roleResourcePermissionDto) {
        return roleResourcePermissionMapperExt.deleteByPrimaryKey(DozerUtils.map(roleResourcePermissionDto,RoleResourcePermissionKey.class))>0;
    }

    @Override
    public Boolean deleteByKey(RoleResourcePermissionDto roleResourcePermissionDto) {
        return roleResourcePermissionMapperExt.deleteByKey(roleResourcePermissionDto)>0;
    }

    @Override
    public List<RoleResourcePermissionDto> selectList(RoleResourcePermissionDto roleResourcePermissionDto) {
        return roleResourcePermissionMapperExt.selectList(roleResourcePermissionDto);
    }

    @Override
    public List<RoleResourcePermissionDto> selectListByRoleIds(String roleIds) {
        return roleResourcePermissionMapperExt.selectListByRoleIds(roleIds);
    }
}
